<template>
    <div style="height: 100%; " class="workspace" id="main-workspace" >
        <single-table
                ref="singleTable"
                :api="api"
                 list-name="supplierList"
                :default-order="defaultOrder"
                quick-query-field="name"
                quick-query-field-name="名称"
                :tool-buttons="toolButtons"
                :columns="columns"
                @edit="evtSingleTableEdit"
        />
    </div>
</template>
<script>
    import singleTable from "@/itsoftUI/components/table/singleTable"
    import {apiReport} from "@/itsoftUI/report/apiReport";
    import { getPremission } from "@/itsoftUI/auth/permission";
    export default {
        name: "reportList",
        components: { singleTable},
        data() {
            return {
                api:apiReport,
                defaultOrder: {prop: 'serialnum', order: 'ascending'},
                toolButtons:[
                    { text:'刷新',icon:'shuaxin',rightLine:true },
                    { text:'新增',icon:'add',auth: '010302'},
                    { text:'编辑',icon:'edit',auth: '010303'},
                    { text:'删除',icon:'delete',auth: '010304',rightLine:true}
                ],
                winTitle: '',
                editID: '0',
                //列
                columns: [
                    {
                        prop: 'type', label: '类型', sortable: true, width: '90', visible: true
                    },
                    {
                        prop: 'module', label: '所属模块', sortable: true, width: '100', visible: true
                    },
                    {
                        prop: 'serialnum', label: '编码', sortable: true, width: '80', visible: true
                    },
                    {
                        prop: 'name',
                        label: '名称',
                        sortable: true,
                        width: '220',
                        visible: true,
                        fixed: false,
                        tooltip: true,
                        max: 10
                    },
                    {
                        prop: 'remark',
                        label: '备注',
                        sortable: true,
                        resizable: false,
                        width: '',
                        visible: true,
                        tooltip: true,
                        max: 100
                    },
                    {
                        prop: 'edituser', label: '编辑用户', sortable: true, width: '100', visible: true
                    },
                    {
                        prop: 'edittime',
                        label: '编辑时间',
                        sortable: true,
                        width: '150',
                        align: 'center',
                        visible: true,
                        type: 'date'
                    },
                ],
                //默认查询
                defaultSearch: {
                    "andOr": "and",
                    "searchField": "schoolcode",
                    "operator": "=",
                    "searchValue": this.$itsoftUI.config.schoolCode
                },
                quickQueryField: "name",
                quickQueryFieldName: '名称',
                queryList: null, //查询条件
                isExport: false,

            }
        },
        methods: {
            //编辑、添加
            evtSingleTableEdit(val) {
                if (val) {
                    let edit = this.toolButtons.filter(item => item.auth === "010303");
                    if (edit && edit.length > 0 && edit[0].disabled) return false;
                    this.editID = val.id
                    //打开连接
                    this.$router.push({path: '/itreport/design/' + this.editID})
                } else {
                    this.editID = "0";
                        //打开连接
                    this.$router.push({path: '/itreport/design/' + this.editID})
                }
            },

        }
        ,computed: {

        },
        created() {
            //功能权限
            getPremission(this.toolButtons);
        }
    }
</script>

